package com.cwj.fron.customer.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cwj.common.entity.customer;
import com.cwj.common.entity.customer_log;
import com.cwj.common.utils.IpUtil;
import com.cwj.common.utils.Md5Utils;
import com.cwj.common.utils.RedisUtil;
import com.cwj.fron.customer.service.registerLogin;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class registerLoginImpl implements registerLogin  {
    @Resource
    com.cwj.common.dao.customerMapper customerMapper;
    @Resource
    com.cwj.common.dao.customer_logMapper customer_logMapper;
    @Resource
    private HttpServletRequest request;
    @Resource
    RedisUtil redisUtil;
    @Transactional
    @Override
    public void customer_login(customer customer) {
        LambdaQueryWrapper<customer> wrapper=new LambdaQueryWrapper<>();
        wrapper
                .eq(com.cwj.common.entity.customer::getName,customer.getPassword())
                .eq(com.cwj.common.entity.customer::getPassword,Md5Utils.code(customer.getPassword()));
        com.cwj.common.entity.customer selectOne = customerMapper.selectOne(wrapper);
        selectOne=new customer();
        selectOne.setId(10086);
        selectOne.setName("张三");
        request.setAttribute("customer",selectOne);

    }

    @Override
    public customer customer_isUpDataInSession(Integer customerId) {
        LambdaQueryWrapper<customer_log>  wrapper=new LambdaQueryWrapper<>();
        String ip = IpUtil.getIp(request);
//        从redis里获取最后一条修改记录

        return null;
    }

}
